package com.ssh.controller;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.ssh.entity.User;
import com.ssh.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @author yang
 */
@Controller
@RequestMapping("/userTest")
public class TestAction {
    @Autowired
    private UserService userService;
    @RequestMapping("/addOne")
    public String addOneMethod(User user,Model m){
        m.addAttribute("message","添加成功！");
        userService.save(user);
        return "index";
    }
    @RequestMapping("/getOne")
    public String getOneMethod(int id,Model m){
        m.addAttribute("user",userService.load(id));
        m.addAttribute("message","获取成功！");
        return "index";
    }
}
